{include file="header.html"}
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/highcharts/highcharts.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/statistics.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/jquery.ui/jquery.ui.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/jquery.ui/i18n/zh-CN.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/timepicker/js/jquery-ui-timepicker-addon.js" ></script>
<link rel="stylesheet" type="text/css" href="/includes/libraries/javascript/jquery.ui/themes/ui-lightness/jquery.ui.css"  />

{include file=subnav.html}
<div id="rightTop">
    <p>{$lang.ad}</p>
    <ul class="subnav">
        <li><a class="btn1" href="index.php?app=wish_activity">{$lang.manage}</a></li>
        <li><span>{$lang.edit}</span></li>
    </ul>
</div>

<div class="info">
    <form id="theme_form" method="post" enctype="multipart/form-data">
        <table class="infoTable">
            <tr>
                <th class="paddingT15">
                    备注:</th>
                <td class="paddingT15 wordSpacing5" >
                    <input class="infoTableFile2" id="theme_title" name="remark" value="{$info.remark}"/>
                    <input type="hidden" name="activity_id" value="{$info.activity_id}">
                </td>
            </tr>

            <tr>
                <th class="paddingT15">
                    设置开始时间:</th>
                <td class="paddingT15 wordSpacing5" >
                    <div  class="left">
                        <input class="txt date" readonly type="text" value="{$info.start_time|date:Y-m-d}" id="start_time" name="start_time">
                    </div>
                </td>
            </tr>
            <tr>
                <th class="paddingT15">
                    设置结束时间:</th>
                <td class="paddingT15 wordSpacing5" >
                    <div  class="left">
                        <input class="txt date" readonly type="text" value="{$info.end_time|date:Y-m-d}" id="end_time" name="end_time">
                    </div>
                </td>
            </tr>
            <tr>
                <th class="paddingT15">
                    选择图片:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="wish_activity_url" type="file" name="wish_activity_url" />
                    <label class="field_notice">支持格式gif,jpg,jpeg,png</label>
                </td>
            </tr>
            {if $info.wish_activity_url}
            <tr>
                <th class="paddingT15">
                </th>
                <td class="paddingT15 wordSpacing5">
                    <img src="{$info.wish_activity_url}?{$random_number}" class="makesmall" max_width="120" max_height="90" />
                </td>
            </tr>
            {/if}
            <tr>
                <th class="paddingT15">
                    选择类型:</th>
                <td class="paddingT15 wordSpacing5">
                    {html_radios options=$yes_or_no checked=$info.type name=type}</td>
            </tr>
            <tr>
                <th class="paddingT15">
                   选择商品:</th>
                <td class="paddingT15 wordSpacing5">
                    <button class="formbtn cart-add" type="button">选择</button>
                    <div class="choose_goods" style="padding-top:20px ">
            <tr class="tatr1" id="after">
                <td width="15%"><span  fieldname="goods_name">商品名称</span></td>
                <td width="2%"><span  fieldname="total_inventory">总库存</span></td>
                <td width="15%"><span  fieldname="stock_name">发货地</span></td>
                <td width="15%"><span  fieldname="times">年代</span></td>
                <td width="25%"><span  fieldname="international_code">国际码</span></td>
                <td width="5%"><span  fieldname="sort_order">排序</span></td>
                <td width="20%"><span  fieldname="default_image">默认图</span></td>
                <td width="20%"><span  fieldname="views">操作</span></td>
            </tr>

            <!--{foreach from=$info.goods item=bg}-->
            <tr class="tatr1">
                <td class="table-center">
                    <label style="padding: 5px; border:1px solid #e3e3e3 ;" name="goods" value="{$bg.goods_id}">{$bg.goods_name}</label>
                </td>
                <td class="table-center">
                    <label style="padding: 5px; border:1px solid #e3e3e3 ;" name="goods" value="{$bg.goods_id}">{$bg.total_inventory}</label>
                </td>
                <td class="table-center">
                    <label style="padding: 5px; border:1px solid #e3e3e3 ;" name="goods" value="{$bg.goods_id}">{$bg.stock_name}</label>
                </td>
                <td class="table-center">
                    <label style="padding: 5px; border:1px solid #e3e3e3 ;" name="goods" value="{$bg.times}">{$bg.times|default='无'}</label>
                </td>
                <td class="table-center">
                    <label style="padding: 5px; border:1px solid #e3e3e3 ;" name="goods" value="{$bg.goods_id}">{$bg.international_code}</label>
                </td>
                <td class="table-center">
                    <input style="width: 40px;" name="goodsSorts[]" type="text" class="infoTableInput2"  value="{$bg.sort_order}">
                </td>
                <td class="table-center"><img  height="80" src="{$bg.default_image}" /></td>
                <td class="table-center">
                    <input type="checkbox" checked style="display: none" value="{$bg.goods_id}" name="goods"><img style="margin-right: 10px;width:15px;height: 15px;" src="templates/style/images/close.gif" onclick="dropGoods(this)" fieldname="mall_recommended" fieldid="{$bg.goods_id}" fieldvalue="1" title="{$lang.editable}"/>
                </td>
            </tr>
            <!--{/foreach}-->
            <input id="goods_id" name="goods_id" style="display: none" value="{$ids}">
            </td>
            </tr>

            <tr>
                <th></th>
                <td class="ptb20">
                    <input class="formbtn" type="submit" name="Submit" value="{$lang.submit}" />
                    <input class="formbtn" type="reset" name="Submit2" value="{$lang.reset}" />
                </td>
            </tr>
        </table>
    </form>

    <div class = "bg-model" style="position:absolute;top:0%;left:0%;display:none;background:rgba(0,0,0,0.3);width:100%;height:100%;position:fixed;z-index:9999">
        <iframe src="index.php?app=wish_activity&act=iframe" id="goods_page" width="90%" height="90%"></iframe>
    </div>
</div>
<script>
</script>
{include file="footer.html"}
<script>
    var goods_id = '';
    $(function () {
        $('#start_time').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
            autoclose: true,
            minView: 0,
            language : 'zh-CN',
            minuteStep:1
        });
        $('#end_time').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
            autoclose: true,
            minView: 0,
            language : 'zh-CN',
            minuteStep:1
        });
    })

    $(".cart-add").click(function () {
        $("iframe").contents().find(".checkitem:checked");
        $("iframe").contents().find(".checkitem:checked").each(function () {
            $(this).removeAttr('checked');
        })
        $("iframe").contents().items = '';
        $(".bg-model").fadeTo(300,1)
        //隐藏窗体的滚动条
        $("body").css({ "overflow": "hidden" });
    });


    //模态框OK按钮点击事件
    $(".bg-model-ok").click(function () {
        $(".bg-model").hide();
        //显示窗体的滚动条
        $("body").css({ "overflow": "visible" });
    }).hover(function () {
        $(this).css({ "backgroundColor": "#8CC8C8" });
    }, function () {
        $(this).css({ "backgroundColor": "#8CD4E6" });
    });
    $("#enter").click(function () {
        var items = '';
        var name = '';
        $('.checkitem:checked').each(function(){
            items += this.value + ',';
            name += $(this).attr('attr-name') + ','
        });
        items = items.substr(0, (items.length - 1));
        name = name.substr(0, (name.length - 1));
        var items_arr = items.split(',');
        var name_arr = name.split(',');
        for(var i in items_arr){
            $(".choose_goods").append('<label style="padding: 5px; border:1px solid #e3e3e3" name="goods" value="'+items_arr[i]+'">'+name_arr[i]+'</label><input type="checkbox" checked style="display: none" value="'+items_arr[i]+'" name="goods"><img style="margin-right: 10px;width:15px;height: 15px;" src="templates/style/images/close.gif" onclick="dropGoods(this' +
                ')" fieldname="mall_recommended" fieldid="{$goods.goods_id}" fieldvalue="1" title="{$lang.editable}"/>');
        }
        $('#goods_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
        $(".bg-model").hide();
        //显示窗体的滚动条
        $("body").css({ "overflow": "visible" });
    })
    function dropGoods(obj) {
        $(obj).parent().parent().remove();
        $(obj).remove()
        $('#goods_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
    }

</script>
